package com.emm.yixun.website.service.oa.leave;

import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.emm.yixun.website.entity.oa.leave.Leave;
import com.emm.yixun.website.repository.oa.leave.LeaveDao;
import com.emm.yixun.website.service.base.BaseServiceImp;
@Service("OaLeaveService")
public class LeaveServiceImp extends BaseServiceImp<Leave> implements LeaveService {

	@Override
	public Leave findLeaveByPId(String pId) {
		return ((LeaveDao)baseDao).findLeaveByPId(pId);
	}

	@Override
	public void updateRejectReason(String pId,String rejectReason) {
		Leave l=new Leave();
		l.setpId(pId);
		l.setRejectReason(rejectReason);
		l.setUpdateTime(new Date());
		((LeaveDao)baseDao).updateRejectReason(l);
	}

	@Override
	public void updateDescription(String pId,String description) {
		Leave l=new Leave();
		l.setpId(pId);
		l.setDescription(description);
		l.setUpdateTime(new Date());
		((LeaveDao)baseDao).updateDescription(l);
	}
	
	@Transactional(propagation=Propagation.REQUIRED)
	@Override
	public void testTransactional() {
		Leave l=new Leave();
		l.setId("1111");
		l.setpId("1111");
		l.setRejectReason("11111");
		l.setUpdateTime(new Date());
		((LeaveDao)baseDao).insert(l);
		
		
		l=new Leave();
		l.setId("2222");
		l.setpId("2222");
		l.setRejectReason("2222");
		l.setUpdateTime(new Date());
		((LeaveDao)baseDao).insert(l);
		if(true){
			throw new RuntimeException("阻断");
		}
		l=new Leave();
		l.setId("3333");
		l.setpId("3333");
		l.setRejectReason("3333");
		l.setUpdateTime(new Date());
		((LeaveDao)baseDao).insert(l);
	}
}
